import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import { Spin } from 'antd';
import moment from 'moment';
import 'moment/locale/zh-cn';
import router from 'umi/router';
// import XLSX from '../../assets/xlsx.min';
// import * as XLSX from 'xlsx-style';
import {
  Row,
  Col,
  Card,
  Form,
  Input,
  Select,
  Icon,
  Button,
  Dropdown,
  Menu,
  InputNumber,
  DatePicker,
  Modal,
  message,
  Badge,
  Divider,
  Steps,
  Radio,
  Table,
  Popconfirm,
} from 'antd';
import StandardTable from '@/components/StandardTable';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import styles from './Test.less';

moment.locale('zh-cn');
// import TableForm from './TableForm';
const listernerable = false;
let nowFormData;
const FormItem = Form.Item;
const { Step } = Steps;
const { TextArea } = Input;
const { Option } = Select;
const RadioGroup = Radio.Group;
const getValue = obj =>
  Object.keys(obj)
    .map(key => obj[key])
    .join(',');
const statusMap = ['default', 'processing', 'success', 'error'];

/* eslint react/no-multi-comp:0 */
// @connect(({ monitor, loading }) => ({
//   monitor,
//   loading: loading.models.ruleTest,
// }))

@Form.create()
// @connect(({ form1, loading }) => ({
//   form1,
//   submitting: loading.effects['form/submitAdvancedForm'],
// }))
class UpdateForm extends PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      formVals: {
        id: props.values.id,
        type: props.values.type || 0,
        code: props.values.code,
        stikeprice: props.values.stikeprice,
        expiration: props.values.expiration,

        premium: props.values.premium,
        contracts: props.values.contracts,
        turnflag: props.values.turnflag,
      },
      currentStep: 0,
    };
    this.formLayout = {
      labelCol: { span: 7 },
      wrapperCol: { span: 13 },
    };
  }

  handleAddOrUpdate = currentStep => {
    const { form, handleUpdate } = this.props;
    const { formVals: oldValue } = this.state;
    form.validateFields((err, fieldsValue) => {
      if (err) return;
      const formVals = { ...oldValue, ...fieldsValue };
      this.setState(
        {
          formVals,
        },
        () => {
          handleUpdate(formVals);
          // console.log()
        }
      );
    });
  };

  renderFooter = currentStep => {
    const { handleUpdateModalVisible, values } = this.props;

    return [
      <Button key="cancel" onClick={() => handleUpdateModalVisible(false, values)}>
        取消
      </Button>,
      <Button key="submit" type="primary" onClick={() => this.handleAddOrUpdate(currentStep)}>
        提交
      </Button>,
    ];
  };

  renderContent = formVals => {
    const { record, isUpdate } = this.props;
    const { form } = this.props;
    console.log(this.props);
    const formatTime = timeStr => {
      console.log(timeStr, typeof timeStr);
      if (typeof timeStr === 'string') {
        const nowyear = `${new Date().getFullYear()}`;
        return nowyear + timeStr.replace(/[\u4e00-\u9fa5]/g, '');
      }
    };
    // var chengjiao = this.props.values.turnflag ? <FormItem key="turnovertime" {...this.formLayout} label="成交时间">
    //   {form.getFieldDecorator('turnovertime', {
    //     rules: [{ required: true, message: '请输入成交时间！' }],
    //     initialValue: moment(formatTime(formVals.turnovertime), 'YYYY-MM-DD'),
    //   })(<DatePicker format={'YYYY-MM-DD'} />)}
    // </FormItem> : <FormItem></FormItem>;
    return [
      <FormItem key="type" {...this.formLayout} label="类型">
        {form.getFieldDecorator('type', {
          initialValue: { 1: 'Sell Call', 0: 'Sell Put', 2: 'Buy Put', 3: 'Buy Call' }[
            formVals.type
          ],
          // initialValue: formVals.type,
          rules: [{ required: true, message: '请输入类型！' }],
        })(
          <Select style={{ width: '100%' }} placeholder="请选择类型">
            <Option value="0">Sell Call</Option>
            <Option value="1">Sell Put</Option>
            <Option value="2">Buy Put</Option>
            <Option value="3">Buy Call</Option>
          </Select>
        )}
      </FormItem>,
      <FormItem key="code" {...this.formLayout} label="股票代码">
        {form.getFieldDecorator('code', {
          rules: [{ required: true, message: '请输入股票代码！' }],
          initialValue: formVals.code,
        })(<Input placeholder="请输入股票代码" />)}
      </FormItem>,

      // chengjiao,
      // <FormItem key="name" {...this.formLayout} label="市场价格">
      //   {form.getFieldDecorator('monthOptionVolume', {
      //     rules: [{ required: true, message: '请输入市场价格！' }],
      //     initialValue: formVals.monthOptionVolume,
      //   })(<Input placeholder="请输入市场价格" />)}
      // </FormItem>,
      <FormItem key="stikeprice" {...this.formLayout} label="执行价格">
        {form.getFieldDecorator('stikeprice', {
          rules: [
            { required: true, message: '请输入执行价格' },
            {
              pattern: /^(\d+)((?:\.\d+)?)$/,
              message: '请输入合法金额数字',
            },
          ],
          initialValue: formVals.stikeprice,
        })(<Input placeholder="请输入 执行价格" prefix="$" />)}
      </FormItem>,
      // <FormItem key="expiration" {...this.formLayout} label="到期日">
      //   {form.getFieldDecorator('expiration', {
      //     rules: [{ required: true, message: '请输入到期日！' }],
      //     initialValue: formVals.expiration
      //   })(<Input placeholder="请输入到期日！" />)}
      // </FormItem>,
      <FormItem key="expiration" label="到期日" labelCol={{ span: 7 }} wrapperCol={{ span: 15 }}>
        {form.getFieldDecorator('expiration', {
          initialValue: !isUpdate ? moment(formVals.expiration, 'YYYY/MM/DD') : '',
          rules: [{ required: true, message: '请输入到期日!' }],
        })(<DatePicker />)}
      </FormItem>,
      <FormItem key="premium" {...this.formLayout} label="权利金">
        {form.getFieldDecorator('premium', {
          rules: [{ required: true, message: '请输入权利金！' }],
          initialValue: formVals.premium,
        })(<Input placeholder="请输入权利金" prefix="$" />)}
      </FormItem>,
      <FormItem key="contracts" {...this.formLayout} label="最多合约数">
        {form.getFieldDecorator('contracts', {
          rules: [{ required: true, message: '请输入最多合约数！' }],
          initialValue: formVals.contracts,
        })(<Input placeholder="请输入最多合约数" />)}
      </FormItem>,
    ];
  };

  render() {
    const { updateModalVisible, handleUpdateModalVisible, values } = this.props;
    const { currentStep, formVals } = this.state;
    return (
      <Modal
        width={640}
        bodyStyle={{ padding: '32px 40px 48px' }}
        destroyOnClose
        title="修改信息"
        visible={updateModalVisible}
        footer={this.renderFooter(currentStep)}
        onCancel={() => handleUpdateModalVisible(false, values)}
        afterClose={() => handleUpdateModalVisible()}
      >
        {this.renderContent(formVals)}
      </Modal>
    );
  }
  // formDealSelectChange=(formVals)=>{
  //   console.log(formVals)
  //   const { dispatch } = this.props;
  //   const { formValues } = this.state;

  //   dispatch({
  //     type: 'form1/UpdateOption',
  //     payload: {
  //       id: formVals.id,
  //       turnovertime: '2019-04-26 22:01:04',
  //       flag: formVals.turnflag,
  //     },
  //     callback: () => {
  //       message.success('更改成功!');
  //       this.handleUpdateModalVisible();
  //       // dispatch({
  //       //   type: 'rule/GetUpsOptionList',
  //       //   payload: formValues,
  //       // });
  //     },
  //   });

  // };
}
@connect(({ monitor, loading }) => ({
  monitor,
  submitting: loading.effects['form/submitAdvancedForm'],
}))
class OptionsIn extends PureComponent {
  index = 0;

  cacheOriginData = {};

  state = {
    dateList: ['今日'],
    filterData: [],
    expandForm: false, // 查询菜单栏 是否显示
    listLoading: false,
    formValues: {
      method: 'GetList',
      page: 1,
      pagesize: 200,
      type: 3,
      name: '',
    }, // 查询菜单栏   查询参数
    isUpdate: false,
    record: {},
    modalVisible: false,
    updateModalVisible: false,
    selectedRows: [],
    stepFormValues: {},
  };

  // 默认加载数据-起始方法
  render() {
    const { isUpdate, record } = this.state;

    const {
      monitor: { data },
      loading,
      total,
    } = this.props;
    const {
      dateList,
      selectedRows,
      modalVisible,
      updateModalVisible,
      stepFormValues,
      selectItem,
      listLoading,
    } = this.state;

    this.state.data = data.data;
    // this.setState({
    //   data:data.data
    // })
    const children = [];
    if (dateList.length > 0) {
      for (let i = 0; i < dateList.length; i++) {
        children.push(
          <Option key={!dateList[i] ? ' ' : dateList[i].substring(0, 10)}>
            {!dateList[i] ? ' ' : dateList[i].substring(0, 10)}
          </Option>
        );
      }
    }
    const updateMethods = {
      handleUpdateModalVisible: this.handleUpdateModalVisible,
      handleUpdate: this.handleUpdate,
    };
    const columns = [
      // {
      //   title: '',
      //   dataIndex: 'id',
      //   render: text => <span>{}</span>,
      // },
      {
        title: '类型',
        dataIndex: 'type',
        editable: true,
        width: 100,

        render: text => (
          <span>{{ 1: 'Sell Call', 0: 'Sell Put', 2: 'Buy Put', 3: 'Buy Call' }[text]}</span>
        ),
      },
      {
        title: '股票代码',
        dataIndex: 'code',
        width: 140,
        render: (text, record) => {
          if (record.editable) {
            return (
              <Input
                value={text}
                autoFocus
                onChange={e => this.handleFieldChange(e, 'name', record.key)}
                onKeyPress={e => this.handleKeyPress(e, record.key)}
                placeholder="成员姓名"
              />
            );
          }
          return text;
        },
      },

      {
        title: '执行价格',
        width: 160,
        dataIndex: 'stikeprice',
        render: text => <span>{text ? `$${text}` : ' '}</span>,
      },
      {
        title: '到期日',
        width: 120,
        dataIndex: 'expiration',
        render: text => <span>{text || ' '}</span>,
      },

      {
        title: '权利金',
        width: 110,
        dataIndex: 'premium',
        render: text => <span>{text ? `$${text}` : ' '}</span>,
      },
      {
        title: '最多合约数',
        width: 110,
        dataIndex: 'contracts',
        render: text => <span>{text || ' '}</span>,
      },

      // {
      //   title: '订单有效期',
      //   width: 120,
      //   dataIndex: 'validity',
      //   render: text => <span>{text ? text : ' '}</span>,
      // },

      // {
      //   title: '分析',
      //   width: 100,
      //   dataIndex: 'turnflag',
      //   render: text => <span>{text ? '成交' : ' '}</span>,
      // },
      {
        title: '操作',
        width: 100,
        render: (text, record) => {
          if (record.type != 0 && !record.type) {
            return null;
          }
          return (
            <Fragment>
              <Popconfirm
                title="是否要删除此条？"
                onConfirm={() => this.handleRemoveModalVisible(record)}
              >
                <a style={{ marginRight: '4px' }}>删除</a>
              </Popconfirm>
              <Divider type="vertical" />
              <a onClick={() => this.handleUpdateModalVisible(true, record)}>更改</a>
            </Fragment>
          );
        },
      },
    ];
    return (
      <PageHeaderWrapper title="盘中期权成交监控">
        <div className={styles.controlBar}>
          <div
            style={{
              display: 'flex',
              flexFlow: 'row wrap',
              alignContent: 'space-between',
              alignItems: 'center',
            }}
          >
            {/* <Button onClick={this.optionsClear}>清空</Button> */}
            <Button
              icon="plus"
              type="primary"
              onClick={() => this.handleUpdateModalVisible(true, this.state.formValues)}
            >
              新建
            </Button>
          </div>
          <div
            style={{
              display: 'flex',
              flexFlow: 'row wrap',
              alignContent: 'space-between',
              alignItems: 'center',
              textAlign: 'center',
              justifyContent: 'center',
            }}
          >
            <span
              style={{
                fontSize: 16,
                // textAlign: 'left',
                fontWeight: '600',
                marginLeft: '1em',
                marginBottom: '4px',
                height: '32px',
                lineHeight: '32px',
              }}
            >
              按日期查询
            </span>
            <Select
              defaultValue="今日"
              style={{ marginLeft: '1em', width: '8em', marginBottom: '4px' }}
              onChange={this.handleChange.bind(this)}
            >
              {children}
            </Select>
          </div>
        </div>
        <Card bordered={false}>
          <div className={styles.tableList}>
            {/*      <div className={styles.tableListForm}>{this.renderForm()}</div> */}
            {/* <StandardTable
              rowClassName={this.rowClassName}
              selectedRows={selectedRows}
              loading={listLoading}
              data={this.state.data}
              columns={this.columns}
              onChange={this.handleStandardTableChange}
              rowKey="id"
              pagination="false"
              hideOnSinglePage
              pagination={false}
            /> */}
            <Table
              rowKey="id"
              scroll={{ x: 1200, y: 650 }}
              columns={columns}
              dataSource={this.state.data}
              pagination={false}
              rowClassName={this.rowClassName}
            />
          </div>
        </Card>
        {stepFormValues && Object.keys(stepFormValues).length ? (
          <UpdateForm
            isUpdate={isUpdate}
            {...updateMethods}
            updateModalVisible={updateModalVisible}
            values={stepFormValues}
          />
        ) : null}
      </PageHeaderWrapper>
    );
  }

  handleUpdateModalVisible = (flag, record) => {
    this.setState({
      isUpdate: !!flag,
      updateModalVisible: !!flag,
      stepFormValues: record || {},
    });
  };

  handleRemoveModalVisible = record => {
    const { data } = this.state;
    const { onChange } = this.props;
    // const newData = data.filter(item => item.id !== key);
    const { dispatch } = this.props;
    dispatch({
      type: 'monitor/UpdateOption',
      payload: {
        id: record.id,
        flag: false,
      },
      callback: res => {
        if (res.code == 1) {
          message.success('删除成功!');
          dispatch({
            type: 'monitor/changeTurnOverMonitorList',
            payload: {
              date: nowFormData,
            },
          });
        }
      },
    });
    // this.setState({ data: newData });
    // onChange(newData);
  };

  handleUpdate = fields => {
    const { dispatch } = this.props;
    const { formValues } = this.state;
    console.log(fields, 'fields');
    // var turnovertime=fields.turnovertime+'';
    // if (fields.turnflag == '成交') {
    //   fields.turnflag = true
    // } else if (fields.turnflag == '不成交') {
    //   fields.turnflag = false
    // }
    if (fields.type == 'Sell Call') {
      fields.type = 1;
    } else if (fields.type == 'Sell Put') {
      fields.type = 0;
    } else if (fields.type == 'Buy Put') {
      fields.type = 2;
    } else if (fields.type == 'Buy Call') {
      fields.type = 3;
    }

    // function getDate() {
    //   var myDate = new Date();
    //   var year = myDate.getFullYear();
    //   var month = myDate.getMonth() + 1;
    //   var date = myDate.getDate();
    //   var h = myDate.getHours();
    //   var m = myDate.getMinutes();
    //   var s = myDate.getSeconds();
    //   function conver(s) {
    //     return s < 10 ? '0' + s : s;
    //   }
    //   var now = year + '-' + conver(month) + "-" + conver(date) + " " + conver(h) + ':' + conver(m) + ":" + conver(s);
    //   return now;
    // }

    // if (!fields.turnovertime) {
    //   fields.turnovertime = getDate();
    // }
    // dispatch({
    //   type: 'monitor/TradingUploadOrder',
    //   payload: {
    //     id: fields.id,
    //     turnovertime: moment(fields.turnovertime).format('YYYY-MM-DD') + ' 00:00:00',
    //     turnflag: fields.turnflag,
    //   },
    //   callback: () => {
    //     this.handleUpdateModalVisible();
    //     dispatch({
    //       type: 'monitor/TradingGetList',
    //       payload: {
    //         date: nowFormData,
    //       },
    //     });
    //   },
    // });
    var fields = fields;
    fields.expiration = `${moment(fields.expiration).format('YYYY-MM-DD')} 00:00:00`;
    // fields.turnovertime = moment(fields.turnovertime).format('YYYY-MM-DD') + ' 00:00:00';
    // delete fields.turnflag;
    dispatch({
      type: 'monitor/TradingUploadOrder',
      payload: fields,
      callback: () => {
        message.success('更改成功!');
        this.handleUpdateModalVisible();
        dispatch({
          type: 'monitor/TradingGetList',
          payload: {
            date: nowFormData,
          },
        });
      },
    });
  };

  handleChange = value => {
    console.log(value);
    const { dispatch } = this.props;
    const { formValues } = this.state;
    // value = value.replace(/[^0-9\.]/gi, '');
    // value = value.slice(0, 2) + '-' + value.slice(2);
    nowFormData = value;
    let data = {
      date: value,
    };
    if (value == '') {
      data = {};
    }
    dispatch({
      type: 'monitor/TradingGetByDate',
      payload: data,
      // callback: res => {
      //   if (res.code == 1) {
      //     that.setState({
      //       data: [],
      //     });
      //   }
      // },
    });
  };

  rowClassName = (record, index) => {
    // return Object.keys(record).length < 5 || record.turnflag ? styles.staticRow : '';
    if (Object.keys(record).length < 5) return styles.staticRow;
    if (record.turnflag) return styles.dealRow;
  };
  // optionsClear = () => {
  //   var that = this;
  //   const { dispatch } = this.props;
  //   const { formValues } = this.state;
  //   dispatch({
  //     type: 'monitor/DelMonitor',
  //     payload: formValues,
  //     callback: res => {
  //       message.success('清空成功!');
  //     },
  //   });
  // };
  // optionsUpload = () => {
  //   var clearBtn = document.querySelector('.clear_handPanel');
  //   var that = this;
  //   document.querySelector('.fileipt').click();
  //   var $fileipt = document.querySelector('.fileipt');
  //   // $fileipt.addEventListener('change', uploadExcel);
  //   if ($fileipt.getAttribute('change') !== '1') {
  //     $fileipt.setAttribute('change', '1');
  //     $fileipt.addEventListener('change', uploadExcel);
  //   }
  //   function uploadExcel() {
  //     if (!this.files) {
  //       return;
  //     }
  //     var f = this.files[0];
  //     parseXLSX(f, function (carData) {
  //       console.log(carData, 'carData')
  //       // $('.optionWatching .optionWatching_btn>input').val('');
  //       var mapobj = [];
  //       var submitData = [];
  //       var iscollected = false;
  //       for (var i = 0, le = carData.length; i < le; i++) {
  //         var len = Object.keys(carData[i]).length;
  //         if (len >= 10 && !iscollected) {
  //           iscollected = true;
  //           for (var j in carData[i]) {
  //             if (carData[i][j].match(/扣佣/)) {
  //               mapobj.annualized = j;
  //             } else if (carData[i][j].match(/年回收/)) {
  //               mapobj.annualized2 = j;
  //             } else if (carData[i][j].match(/股票代/)) {
  //               mapobj.code = j;
  //             } else if (carData[i][j].match(/合约数/)) {
  //               mapobj.contracts = j;
  //             } else if (carData[i][j].match(/到期日天数/)) {
  //               mapobj.dayexp = j;
  //             } else if (carData[i][j].match(/折扣/)) {
  //               mapobj.discount = j;
  //             } else if (carData[i][j].match(/到期日/)) {
  //               mapobj.expiration = j;
  //             } else if (carData[i][j].match(/将开的潜在/)) {
  //               mapobj.openpotential = j;
  //             } else if (carData[i][j].match(/权利金总额/)) {
  //               mapobj.totalpremium = j;
  //             } else if (carData[i][j].match(/权利金/)) {
  //               mapobj.premium = j;
  //             } else if (carData[i][j].match(/执行价格/)) {
  //               mapobj.stikeprice = j;
  //             } else if (carData[i][j].match(/订单有效期/)) {
  //               mapobj.validity = j;
  //             } else if (carData[i][j].match(/归属人/)) {
  //               mapobj.uploader = j;
  //             }
  //           }
  //         } else if (len >= 10 && iscollected) {
  //           var submitDataItem = {};
  //           submitDataItem.type = 0;

  //           var annualized = mapobj.annualized;
  //           var annualized2 = mapobj.annualized2;
  //           var code = mapobj.code;
  //           var contracts = mapobj.contracts;
  //           var dayexp = mapobj.dayexp;
  //           var discount = mapobj.discount;
  //           var expiration = mapobj.expiration;
  //           var openpotential = mapobj.openpotential;
  //           var premium = mapobj.premium;
  //           var stikeprice = mapobj.stikeprice;
  //           var totalpremium = mapobj.totalpremium;
  //           var type = mapobj.type;
  //           var validity = mapobj.validity;
  //           var uploader = mapobj.uploader;
  //           submitDataItem.annualized = carData[i][annualized].toFixed(2) || '';
  //           submitDataItem.annualized2 = carData[i][annualized2].toFixed(2) || '';
  //           submitDataItem.code = carData[i][code] || '';
  //           submitDataItem.contracts = carData[i][contracts] || '';
  //           submitDataItem.dayexp = carData[i][dayexp] || '';
  //           submitDataItem.discount = carData[i][discount].toFixed(2) || '';
  //           submitDataItem.expiration = formatDate(carData[i][expiration]) || '';
  //           submitDataItem.openpotential = carData[i][openpotential] || '';
  //           submitDataItem.premium = carData[i][premium].toFixed(2) || '';
  //           submitDataItem.stikeprice = carData[i][stikeprice] || '';
  //           submitDataItem.totalpremium = carData[i][totalpremium].toFixed(2) || '';
  //           submitDataItem.uploader = carData[i][uploader] || '';

  //           submitDataItem.validity = formatDate(carData[i][validity]) || '';
  //           for (var k in carData[i]) {
  //             if ((carData[i][k] + '').match(/Sell Call/i)) {

  //               submitDataItem.type = 1;
  //             } else if ((carData[i][k] + '').match(/Buy Put/i)) {
  //               submitDataItem.type = 2;
  //             } else if ((carData[i][k] + '').match(/Buy Call/i)) {
  //               submitDataItem.type = 3;
  //             }
  //           }
  //           submitData.push(submitDataItem);
  //         }
  //       }
  //       const { dispatch } = that.props;
  //       const { formValues } = that.state;

  //       dispatch({
  //         type: 'monitor/upTurnOverMonitor',
  //         payload: submitData,
  //         callback: res => {
  //           $fileipt.value = '';
  //           message.success('上传成功!');
  //           dispatch({
  //             type: 'monitor/changeTurnOverMonitorList',
  //             payload: { date: '今日' },
  //           });
  //           this.setState({
  //             listLoading: false,
  //           });
  //         },
  //       });
  //       console.log(submitData, 'submitData');
  //     });
  //     function format(carData) {
  //       var obj = {};
  //       var reg = /(\ )|(\")|(\')|(\r)|(\n)|(\,)/g;
  //       for (var i = 0, len = carData.length; i < len; i++) {
  //         for (j in carData[i]) {
  //           if (!obj[j]) {
  //             obj[j] = [];
  //           }
  //           obj[j].push(carData[i][j].replace(reg, ''));
  //         }
  //       }
  //       obj.userId = localStorage.getItem('userid');
  //       return obj;
  //     }
  //     function formatDate(numb) {
  //       var time = new Date((numb - 1) * 24 * 3600000 + 1);
  //       time.setYear(time.getFullYear() - 70);
  //       var year = time.getFullYear() + '';
  //       var month = time.getMonth() + 1 + '';
  //       var date = time.getDate() + '';

  //       return (month < 10 ? '0' + month : month) + '月' + (date < 10 ? '0' + date : date) + '日';
  //     }
  //   }

  //   function parseXLSX(f, cb) {
  //     var carData;
  //     var wb; //读取完成的数据
  //     var rABS = false; //是否将文件读取为二进制字符串
  //     var reader = new FileReader();
  //     reader.onload = function (e) {
  //       var data = e.target.result;
  //       if (rABS) {
  //         wb = XLSX.read(btoa(fixdata(data)), {
  //           type: 'base64',
  //         });
  //       } else {
  //         wb = XLSX.read(data, {
  //           type: 'binary',
  //         });
  //       }
  //       // carData就是我们需要的JSON数据
  //       console.log(wb, 'wb')
  //       carData = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);

  //       typeof cb == 'function' && cb(carData);
  //     };
  //     if (rABS) {
  //       reader.readAsArrayBuffer(f);
  //     } else {
  //       reader.readAsBinaryString(f);
  //     }
  //     function fixdata(data) {
  //       //文件流转BinaryString
  //       var o = '',
  //         l = 0,
  //         w = 10240;
  //       for (; l < data.byteLength / w; ++l)
  //         o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
  //       o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
  //       return o;
  //     }
  //   }
  // };

  componentWillMount() {
    const that = this;
    const { dispatch } = this.props;
    const { formValues } = this.state;
    dispatch({
      type: 'monitor/TradingGetDateList',
      callback: res => {
        if (res.code == 1) {
          that.setState({
            dateList: ['今日'].concat(res.data),
          });
        }
      },
    });
  }

  componentDidMount() {
    const { dispatch } = this.props;
    const { formValues } = this.state;
    dispatch({
      type: 'monitor/TradingGetList',
      payload: { date: '今日' },
    });
  }
  // 改变每页条数和当前页
  // handleStandardTableChange = (pagination, filtersArg, sorter) => {
  //   const { dispatch } = this.props;
  //   const { formValues } = this.state;
  //   formValues.page = pagination.current;
  //   formValues.pagesize = pagination.pageSize;
  //   const params = {
  //     ...formValues,
  //   };
  //   dispatch({
  //     type: 'monitor/GetFundTwoList',
  //     payload: params,
  //   });
  // };

  // //判断 菜单栏 是 缩放显示 还是 全部展示
  // renderForm() {
  //   const { expandForm } = this.state;
  //   return expandForm ? this.renderAdvancedForm() : this.renderSimpleForm();
  // }
}
function mul(arg1, arg2) {
  if (!arg1 || !arg2) return;
  let m = 0;
  const s1 = arg1.toString();
  const s2 = arg2.toString();
  try {
    m += s1.split('.')[1].length;
  } catch (e) {}
  try {
    m += s2.split('.')[1].length;
  } catch (e) {}
  return (Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) / Math.pow(10, m);
}
export default OptionsIn;
